package lagou.work.model1;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {


        System.out.println("                     -------学生信息管理系统-------    ");
        System.out.println("                            1 ：添加学生信息           ");
        System.out.println("                            2 ：删除学生信息           ");
        System.out.println("                            3 ：修改学生信息           ");
        System.out.println("                            4 ：查询学生信息           ");
        System.out.println("                            5 ：遍历学生信息           ");
        System.out.println("                            6 ：退出学生系统           ");
        System.out.println("                     ---------------------------    ");
        List<Student> list = new ArrayList<>();
        //读取位于student.txt文件下的对象，并返回到list中
        list=Controller.input(list);
        while (true) {
            System.out.println("请输入您要选择的功能的序号");
            Scanner scanner = new Scanner(System.in);
            Integer num = scanner.nextInt();
            switch (num) {
                case 1:
                    try {
                        Controller.add(list);
                    } catch (IdException | AgeException e) {
                        e.printStackTrace();
                    }
                    break;
                case 2:
                    try {
                        Controller.delete(list);
                    } catch (IdException e) {
                        e.printStackTrace();
                    }
                    break;
                case 3:
                    try {
                        Controller.modify(list);
                    } catch (IdException e) {
                        e.printStackTrace();
                    } catch (AgeException e) {
                        e.printStackTrace();
                    }
                case 4:
                    Controller.find(list);
                    break;
                case 5:
                    System.out.println(Controller.getStudents(list));
                    break;
                case 6:
                    Controller.output(list);
                    break;
                default:
                    break;
            }
        }
    }
}

